import { onMounted, onUnmounted, toRefs, reactive } from 'vue';

export default () => {

    const position = reactive({
        x: 0,
        y: 0
    });

    const move =  (e) => {
        position.x = e.clientX;
        position.y = e.clientY;
    };

    onMounted(() => {
        document.addEventListener('mousemove', move)
    });

    onUnmounted(() => {
        document.removeEventListener('mousemove', move);
    });

    return {
        ...toRefs(position)
    }

};